function TreeNode(x) {
    this.val = x;
    this.left = null;
    this.right = null;
}
var a = new TreeNode(1);
var b = new TreeNode(2);
var c = new TreeNode(3);
var d = new TreeNode(4);

a.left = b;
a.right = c;
c.left = d;
function TreeDepth(pRoot)
{
    // write code here
    if(pRoot == null){
        return 0;
    }
    let leftDep = TreeDepth(pRoot.left);
    let rightDep = TreeDepth(pRoot.right);
    return leftDep > rightDep ? (leftDep + 1 ):(rightDep + 1);
}

console.log(TreeDepth(a));

